﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UIT_CV_Management
{
    public partial class UserControlTrenDaiHoc : UserControl
    {
        bool isEverythingOK = false;

        // bool for NghienCuu
        bool isNgayBatDauOK = false;
        bool isNgayKetThucOK = false;
        bool isTenTruongOK = false;
        bool isTenNuocOK = false;
        bool isTenVienOK = false;
        bool isNoiDungOK = false;
        bool isTenLuanAnOK = false;
        bool isNgayBaoVeOK = false;
        bool isNoiBaoVeOK = false;
        bool isNguoiHuongDanOK = false;
        bool isKetQuaOK = false;

        // bool for TotNghiep
        bool isNgayBatDauTTOKs = false;
        bool isNgayKetThucTTOK = false;
        bool isTenTruongTTOK = false;
        bool isTenVienTTOK = false;
        bool isTenNuocTTOK = false;
        bool isNoiDungTTOK = false;

        // object
        DiaDiemThucTap diaDiemThucTap;
        DiaDiemNghienCuu diaDiemNghienCuu;
        ThucTap thucTap = null;
        NghienCuu nghienCuu = null;
        DaoTaoTrenDaiHoc daoTaoTrenDaiHoc;

        public UserControlTrenDaiHoc()
        {
            InitializeComponent();
            this.initLanguage();
            this.hideAllErrorImage();

            // uncheck
            checkBoxNghenCuu.Checked = true;
            checkBoxThucTap.Checked = false;
        }

        private void initLanguage()
        {
            checkBoxNghenCuu.Text = Language._("TRENDAIHOC_FORM_CHECKBOXNGHIENCUU_LBL");
            lblNgayBatDau.Text = Language._("TRENDAIHOC_FORM_NGAYBATDAU_LBL");
            lblNgayKetThuc.Text = Language._("TRENDAIHOC_FORM_NGAYKETTHUC_LBL");
            lblTenVien.Text = Language._("TRENDAIHOC_FORM_TENVIEN_LBL");
            lblTenTruong.Text = Language._("TRENDAIHOC_FORM_TENTRUONG_LBL");
            lblTenNuoc.Text = Language._("TRENDAIHOC_FORM_TENNUOC_LBL");
            lblNoiDung.Text = Language._("TRENDAIHOC_FORM_NOIDUNG_LBL");
            lblTenLuanAn.Text = Language._("TRENDAIHOC_FORM_TENLUANAN_LBL");
            lblNgayBaoVe.Text = Language._("TRENDAIHOC_FORM_NGAYBAOVE_LBL");
            lblNoiBaoVe.Text = Language._("TRENDAIHOC_FORM_NOIBAOVE_LBL");
            lblNguoiHuongDan.Text = Language._("TRENDAIHOC_FORM_NGUOIHUONGDAN_LBL");
            lblKetQUa.Text = Language._("TRENDAIHOC_FORM_KETQUA_LBL");

            checkBoxThucTap.Text = Language._("TRENDAIHOC_FORM_CHECKBOXTHUCTAP_LBL");
            //dtpNgayBatDauThucTap.Text = Language._("TRENDAIHOC_FORM_NGAYBATDAUTHUCTAP_LBL");
            //dtpNgayKetThucThucTap.Text = Language._("TRENDAIHOC_FORM_NGAYKETTHUCTHUCTAP_LBL");
            lblTenTruongThucTap.Text = Language._("TRENDAIHOC_FORM_TENTRUONGTHUOCTAP_LBL");
            lblTenVienThucTap.Text = Language._("TRENDAIHOC_FORM_TENVIENTHUCTAP_LBL");
            lblTenNuocThucTap.Text = Language._("TRENDAIHOC_FORM_TENNUOCTHUCTAP_LBL");
            lblNoiDungThucTap.Text = Language._("TRENDAIHOC_FORM_NOIDUNGTHUCTAP_LBL");
        }

        private void hideAllErrorImage()
        {
            pictureBoxNgayBatDau.Visible = false;
            pictureBoxNgayKetThuc.Visible = false;
            pictureBoxTenTRuong.Visible = false;
            pictureBoxTenVien.Visible = false;
            pictureBoxTenNuoc.Visible = false;
            pictureBoxNoiDUng.Visible = false;
            pictureBoxTenLuanAn.Visible = false;
            pictureBoxNgayBaoVe.Visible = false; ;
            pictureBoxNoiBaoVe.Visible = false;
            pictureBoxNguoiHuongDan.Visible = false;
            pictureBoxKetQuaLuanAn.Visible = false;
            pictureBoxNgayBatDauThucTap.Visible = false;
            pictureBoxNgayKetThucThucTap.Visible = false;
            pictureBoxTenTruongThucTap.Visible = false;
            pictureBoxTenVienThucTap.Visible = false;
            pictureBoxTenNuocThucTap.Visible = false; ;
            pictureBoxNoiDungThucTap.Visible = false;

        }

        private void checkBoxNghenCuu_CheckedChanged(object sender, EventArgs e)
        {
            // check
            if (checkBoxNghenCuu.Checked)
            {
                dtpNgayBatDau.Enabled = true;
                dtpNgayKetThuc.Enabled = true;
                txbTenTruong.Enabled = true;
                textBoxTenVien.Enabled = true;
                textBoxTenNuoc.Enabled = true;
                txbNoiDung.Enabled = true;
                txbNoiDung.Enabled = true;
                dtpNgayBaoVe.Enabled = true;
                txbNoiBaoVe.Enabled = true;
                txbNguoiHuongDan.Enabled = true;
                txbKetQuaLuanAn.Enabled = true;
            }
            else // uncheck
            {
                dtpNgayBatDau.Enabled = false;
                dtpNgayKetThuc.Enabled = false;
                txbTenTruong.Enabled = false;
                textBoxTenVien.Enabled = false;
                textBoxTenNuoc.Enabled = false;
                txbNoiDung.Enabled = false;
                txbNoiDung.Enabled = false;
                dtpNgayBaoVe.Enabled = false;
                txbNoiBaoVe.Enabled = false;
                txbNguoiHuongDan.Enabled = false;
                txbKetQuaLuanAn.Enabled = false;
            }
        }

        private void checkBoxThucTap_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxThucTap.Checked)
            {
                dtpNgayBatDauThucTap.Enabled = true;
                dtpNgayKetThucThucTap.Enabled = true;
                textBoxTenTruongThucTa.Enabled = true;
                textBoxTenVienThucTap.Enabled = true;
                txbTenNuocThucTap.Enabled = true;
                txbNoiDungThucTap.Enabled = true;
            }
            else
            {
                dtpNgayBatDauThucTap.Enabled = false;
                dtpNgayKetThucThucTap.Enabled = false;
                textBoxTenTruongThucTa.Enabled = false;
                textBoxTenVienThucTap.Enabled = false;
                txbTenNuocThucTap.Enabled = false;
                txbNoiDungThucTap.Enabled = false;
            }
        }

        private void dtpNgayBatDau_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            if (dtpNgayBatDau.Value.Date.CompareTo(dtpNgayKetThuc.Value.Date) > 0)
            {
                isHasError = true;
            }
            if (isHasError)
            {
                isNgayBatDauOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                dtpNgayBatDau.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGAYBATDAU_NULL");
                utpTip.Visible = true;
                pictureBoxNgayBatDau.Visible = false;
            }
            else
            {
                isNgayBatDauOK = true;
                dtpNgayBatDau.BackColor = Color.White;
                pictureBoxNgayBatDau.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void dtpNgayKetThuc_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            if (dtpNgayKetThuc.Value.Date.CompareTo(dtpNgayBatDau.Value.Date) < 0)
            {
                isHasError = true;
            }

            if (isHasError)
            {
                isNgayKetThucOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                dtpNgayKetThuc.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGAYKETTHUC_NULL");
                utpTip.Visible = true;
                pictureBoxNgayKetThuc.Visible = false;
            }
            else
            {
                isNgayKetThucOK = true;
                dtpNgayKetThuc.BackColor = Color.White;
                pictureBoxNgayKetThuc.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbTenTruong_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbTenTruong.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenTruongOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbTenTruong.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENTRUONG_NULL");
                utpTip.Visible = true;
                pictureBoxTenTRuong.Visible = false;
            }
            else
            {
                isTenTruongOK = true;
                txbTenTruong.BackColor = Color.White;
                pictureBoxTenTRuong.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void textBoxTenNuoc_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (textBoxTenNuoc.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenNuocOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                textBoxTenNuoc.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENNUOC_NULL");
                utpTip.Visible = true;
                pictureBoxTenNuoc.Visible = false;
            }
            else
            {
                isTenNuocOK = true;
                textBoxTenNuoc.BackColor = Color.White;
                pictureBoxTenNuoc.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbNoiDung_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbNoiDung.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isNoiDungOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbNoiDung.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NOIDUNG_NULL");
                utpTip.Visible = true;
                pictureBoxNoiDUng.Visible = false;
            }
            else
            {
                isNoiDungOK = true;
                txbNoiDung.BackColor = Color.White;
                pictureBoxNoiDUng.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbTenLuanAn_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbTenLuanAn.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenLuanAnOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbTenLuanAn.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENLUANAN_NULL");
                utpTip.Visible = true;
                pictureBoxTenLuanAn.Visible = false;
            }
            else
            {
                isTenLuanAnOK = true;
                txbTenLuanAn.BackColor = Color.White;
                pictureBoxTenLuanAn.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void dtpNgayBaoVe_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            if (dtpNgayBaoVe.Value.Date.CompareTo(dtpNgayBatDau.Value.Date) < 0)
            {
                isHasError = true;
            }

            if (isHasError)
            {
                isNgayBaoVeOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                dtpNgayBaoVe.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGAYBAOVE_NULL");
                utpTip.Visible = true;
                pictureBoxNgayBaoVe.Visible = false;
            }
            else
            {
                isNgayBaoVeOK = true;
                dtpNgayBaoVe.BackColor = Color.White;
                pictureBoxNgayBaoVe.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbNoiBaoVe_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbNoiBaoVe.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isNoiBaoVeOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbNoiBaoVe.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NOIBAOVE_NULL");
                utpTip.Visible = true;
                pictureBoxNoiBaoVe.Visible = false;
            }
            else
            {
                isNoiBaoVeOK = true;
                txbNoiBaoVe.BackColor = Color.White;
                pictureBoxNoiBaoVe.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbNguoiHuongDan_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbNguoiHuongDan.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isNguoiHuongDanOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbNguoiHuongDan.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGUOIHUONGDAN_NULL");
                utpTip.Visible = true;
                pictureBoxNguoiHuongDan.Visible = false;
            }
            else
            {
                isNguoiHuongDanOK = true;
                txbNguoiHuongDan.BackColor = Color.White;
                pictureBoxNguoiHuongDan.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbKetQuaLuanAn_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            float result;
            if (float.TryParse(txbKetQuaLuanAn.Text, out result) == false)
            {
                isHasError = true;
            }
            else
            if ((result < 0) || (result > 10))
            {
                isHasError = true;
            }

            if (isHasError)
            {
                isKetQuaOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbKetQuaLuanAn.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_KETQUA_NULL");
                utpTip.Visible = true;
                pictureBoxKetQuaLuanAn.Visible = false;
            }
            else
            {
                isKetQuaOK = true;
                txbKetQuaLuanAn.BackColor = Color.White;
                pictureBoxKetQuaLuanAn.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void dtpNgayBatDauThucTap_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            if (dtpNgayBatDauThucTap.Value.Date.CompareTo(dtpNgayKetThucThucTap.Value.Date) > 0)
            {
                isHasError = true;
            }

            if (isHasError)
            {
                isNgayBatDauTTOKs = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                dtpNgayBatDauThucTap.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGAYBATDAUTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxNgayBatDauThucTap.Visible = false;
            }
            else
            {
                isNgayBatDauTTOKs = true;
                dtpNgayBatDauThucTap.BackColor = Color.White;
                pictureBoxNgayBatDauThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void dtpNgayKetThucThucTap_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;
            if (dtpNgayKetThucThucTap.Value.Date.CompareTo(dtpNgayBatDauThucTap.Value.Date) < 0)
            {
                isHasError = true;
            }

            if (isHasError)
            {
                isNgayKetThucTTOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                dtpNgayKetThucThucTap.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NGAYKETTHUCTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxNgayKetThucThucTap.Visible = false;
            }
            else
            {
                isNgayKetThucTTOK = true;
                dtpNgayKetThucThucTap.BackColor = Color.White;
                pictureBoxNgayKetThucThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void textBoxTenTruongThucTa_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (textBoxTenTruongThucTa.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenTruongTTOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                textBoxTenTruongThucTa.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENTRUONGTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxTenTruongThucTap.Visible = false;
            }
            else
            {
                isTenTruongTTOK = true;
                textBoxTenTruongThucTa.BackColor = Color.White;
                pictureBoxTenTruongThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void textBoxTenVienThucTap_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (textBoxTenVienThucTap.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenVienTTOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                textBoxTenVienThucTap.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENVIENTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxTenVienThucTap.Visible = false;
            }
            else
            {
                isTenVienTTOK = true;
                textBoxTenVienThucTap.BackColor = Color.White;
                pictureBoxTenVienThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbTenNuocThucTap_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbTenNuocThucTap.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenNuocTTOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbTenNuocThucTap.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENNUOCTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxTenNuocThucTap.Visible = false;
            }
            else
            {
                isTenNuocTTOK = true;
                txbTenNuocThucTap.BackColor = Color.White;
                pictureBoxTenNuocThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        private void txbNoiDungThucTap_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (txbNoiDungThucTap.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isNoiDungTTOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                txbNoiDungThucTap.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_NOIDUNGTHUCTAP_NULL");
                utpTip.Visible = true;
                pictureBoxNoiDungThucTap.Visible = false;
            }
            else
            {
                isNoiDungTTOK = true;
                txbNoiDungThucTap.BackColor = Color.White;
                pictureBoxNoiDungThucTap.Visible = true;
                utpTip.Visible = false;
            }
        }

        public bool isTrenDaiHocOK()
        {
            //Validate
            if (checkBoxNghenCuu.Checked)
            {
                dtpNgayBatDau_Validating(dtpNgayBatDau, null);
                dtpNgayKetThuc_Validating(dtpNgayKetThuc, null);
                txbTenTruong_Validating(txbTenTruong, null);
                textBoxTenNuoc_Validating(textBoxTenNuoc, null);
                txbNoiDung_Validating(txbNoiDung, null);
                txbTenLuanAn_Validating(txbNoiDung, null);
                dtpNgayBaoVe_Validating(dtpNgayBaoVe, null);
                txbNoiBaoVe_Validating(txbNoiBaoVe, null);
                txbNguoiHuongDan_Validating(txbNguoiHuongDan, null);
                txbKetQuaLuanAn_Validating(txbKetQuaLuanAn, null);
            }
            else
            {
                dtpNgayBatDauThucTap_Validating(dtpNgayBatDauThucTap, null);
                dtpNgayKetThucThucTap_Validating(dtpNgayKetThucThucTap, null);
                textBoxTenTruongThucTa_Validating(textBoxTenTruongThucTa, null);
                textBoxTenVienThucTap_Validating(textBoxTenVienThucTap, null);
                txbTenNuocThucTap_Validating(txbTenNuocThucTap, null);
                txbNoiDungThucTap_Validating(txbNoiDungThucTap, null);
            }
            bool checkOne = isNgayBatDauOK && isNgayKetThucOK && isTenTruongOK && isTenVienOK && isTenNuocOK && isNoiDungOK && isTenLuanAnOK
                && isNgayBaoVeOK && isNoiBaoVeOK && isNguoiHuongDanOK && isKetQuaOK;
            bool checkTwo = isNgayBatDauTTOKs && isNgayKetThucTTOK && isTenTruongTTOK && isTenVienTTOK && isTenNuocTTOK && isNoiDungTTOK;

            isEverythingOK = checkOne || checkTwo;

            return isEverythingOK;
        }
        public DaoTaoTrenDaiHoc getDaoTaoTrenDaiHoc()
        {
            if (this.isTrenDaiHocOK())
            {
                // init NghienCUu
                if (checkBoxNghenCuu.Checked)
                {
                    // init DiaDiemNghienCuu
                    diaDiemNghienCuu = new DiaDiemNghienCuu(txbTenTruong.Text, textBoxTenVien.Text, textBoxTenNuoc.Text);

                    //init Nghien Cuu
                    nghienCuu = new NghienCuu(dtpNgayBatDau.Value, dtpNgayKetThuc.Value, txbNoiDung.Text, txbTenLuanAn.Text, dtpNgayBaoVe.Value, txbNoiBaoVe.Text
                        , txbNguoiHuongDan.Text, float.Parse(txbKetQuaLuanAn.Text), diaDiemNghienCuu);
                }
                // init ThucTap
                else
                {
                    // init DiaDiemThucTap
                    diaDiemThucTap = new DiaDiemThucTap(textBoxTenTruongThucTa.Text, textBoxTenVienThucTap.Text, txbTenNuocThucTap.Text);

                    // init ThucTap
                    thucTap = new ThucTap(dtpNgayBatDauThucTap.Value, dtpNgayKetThucThucTap.Value, txbNoiDungThucTap.Text, diaDiemThucTap);

                }

                // init DaoTaoTrenDaiHoc
                daoTaoTrenDaiHoc = new DaoTaoTrenDaiHoc(thucTap, nghienCuu);
            }
            return daoTaoTrenDaiHoc;
        }

        private void textBoxTenVien_Validating(object sender, CancelEventArgs e)
        {
            bool isHasError = false;

            if (textBoxTenVien.Text.Trim() == "")
                isHasError = true;

            if (isHasError)
            {
                isTenVienOK = false;
                
                // change NoiSinh's background color to Tomato
                // Add UserTip
                textBoxTenVien.BackColor = Color.Tomato;
                utpTip.Value = Language._("TRENDAIHOC_FORM_TIP_TENVIEN_NULL");
                utpTip.Visible = true;
                pictureBoxTenVien.Visible = false;
            }
            else
            {
                isTenVienOK = true;
                textBoxTenVien.BackColor = Color.White;
                pictureBoxTenVien.Visible = true;
                utpTip.Visible = false;
            }
        }
    }
}
